package com.xframe.domain;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.Map;

public class CommandModel {


    private static final long serialVersionUID = 2008115314324746336L;

    /**
     * 系统编码
     */
    private String sysCode;
    /**
     * 命令编码
     */
    private String commandCode;
    /**
     * 数据类型
     */
    private String className;
    /**
     * 模型编码
     */
    private String modelCode;
    /**
     * 命令参数
     */
    private String commandArgs;
    /**
     * 命令附加参数
     */
    private Object parameter;

    /**
     * 配置文件key
     */
    private String queryKey = "default";
    /**
     * 版本号
     */
    private String ver = "v1";
    /**
     * 数据体
     */
    private Object commandBody;
    public String getCommandCode() {
        return commandCode;
    }
    public void setCommandCode(String commandCode) {
        this.commandCode = commandCode;
    }
    public String getClassName() {
        return className;
    }
    public void setClassName(String className) {
        this.className = className;
    }
    public String getCommandArgs() {
        return commandArgs;
    }
    public String getSysCode() {
        return sysCode;
    }
    /*public Long getCommandArgsToLong() {
        return Long.valueOf(this.commandArgs);
    }*/
    public void setCommandArgs(String commandArgs) {
        this.commandArgs = commandArgs;
    }

    public Object getCommandBody() {
        return commandBody;
    }

    public Map<String,Object> getCommandBodyByMap() {
        return (Map<String,Object>)commandBody;
    }

    private JSONObject argsMap = null;
    public JSONObject getCommandBodyByJSONObject() {
        if(argsMap == null) {
            String json = JSONUtil.toJsonStr(commandBody);
            argsMap = JSON.parseObject(json);
        }
        return argsMap;
    }

    public ArrayList getCommandBodyByArrayList() {
        return (ArrayList)commandBody;
    }
    public void setCommandBody(Object commandBody) {
        this.commandBody = commandBody;
    }

    public String getModelCode() {
        return modelCode;
    }

    public void setModelCode(String modelCode) {
        this.modelCode = modelCode;
    }

    public String getQueryKey() {
        return queryKey;
    }

    public void setQueryKey(String queryKey) {
        this.queryKey = queryKey;
    }

    public String getVer() {
        return ver;
    }

    public void setVer(String ver) {
        this.ver = ver;
    }

    public Object getParameter() {
        return parameter;
    }

    public void setParameter(Object parameter) {
        this.parameter = parameter;
    }

    public void setSysCode(String sysCode) {
        this.sysCode = sysCode;
    }
}
